<!--
*- coding = utf-8 -*-
#@Time : 2023-04-09 23:09
#@Author : CSDN 沉默小管
#@File : index.vue
#@web  : golangblog.blog.csdn.net
#@Software: WebStorm
-->
<template>
    <view class="image-style">
        <!--    #ifdef MP-WEIXIN-->
        <image :src="props.picUrl"/>
        <!--    #endif-->
        <!--    #ifdef H5 || APP-PLUS-->
        <image v-bind="attrs" :src="props.picUrl"/>
        <!--    #endif-->
    </view>
</template>

<script setup lang="ts">
    import {isArray} from "@/utils/lodash"
    import {onMounted, ref, useAttrs} from "vue";
    interface propsInterface{
        isShowImg?:boolean//是否展示图片
        picUrl:string
        lazy?:boolean
        picList?:any
        attrs?:any
    }

    let props = withDefaults(defineProps<propsInterface>(),{
        picUrl:"",
        picList:[],
        lazy:false,
        isShowImg:true,
        //#ifdef MP-WEIXIN
        attrs:{},
        //#endif
    })
    let attrs;
    //#ifdef H5 || APP-PLUS
    attrs = useAttrs()
    //#endif

    //#ifdef MP-WEIXIN
    attrs = props.attrs
    //#endif
    let initIndex = ref<number>(0)
    let srcList = ref<string[]>([])

    const handleShowImage = ()=>{
      if(!props.isShowImg)return;
      if(props.picList.length>0 && isArray(props.picList)){
        srcList.value = props.picList
      }else{
        srcList.value = [props.picUrl]
      }
      return srcList.value
    }
    onMounted(()=>{
      handleShowImage()
    })
</script>

<style scoped lang="less">
.image-style{
  width: 100%;
    height:100%;
}
</style>
